package com.cfm880.tut1;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * Created by chengfangming on 2017/5/24.
 */
@SpringBootApplication
@EnableScheduling
public class RabbitAmqpTutorialsApplication {
    @Profile("usage_message")
    @Bean
    public CommandLineRunner usage(){
        return new CommandLineRunner() {
            @Override
            public void run(String... strings) throws Exception {
                System.out.println("This app uses spring profiles to control its behavior.\n");
                System.out.println("Sample usage: java -jar rabbit-tutorials.jar --spring.profiles.active=hello-world,sender.\n");

            }
        };
    }

    @Profile("usage_message")
    @Bean
    public CommandLineRunner tutorial(){
        return new RabbitAmqpTutorialsRunner();
    }

    public static void main(String[] args) throws Exception{
        SpringApplication.run(RabbitAmqpTutorialsApplication.class, args);
    }
}
